package com.tarena.lbs.constant;

public enum RoleEnum {
    ADMIN(1, "管理员"),
    USER(2, "普通用户"),
    MERCHANT(3, "商家");

    private int code;
    private String name;

    RoleEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static RoleEnum getByCode(int code) {
        for (RoleEnum role : RoleEnum.values()) {
            if (role.getCode() == code) {
                return role;
            }
        }
        return null;
    }
}
